package itesm.coler.data;

//import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collection;

import javax.sql.RowSet;

import itesm.coler.models.User;

// Interface that all UserDAOs must support
public interface UserDAO {
	 
	
	/**
     * Returns the user from the database matching the given userId, otherwise null.
     * @param userId The userId of the user to be returned.
     * @return The user from the database matching the given userId, otherwise null.
     * @throws DAOException If something fails at database level.
     */
	 public User findUserByUserId(String userId) throws DAOException;

	 
	/**
     * Returns the user from the database matching the given userName, otherwise null.
     * @param username The userName of the user to be returned.
     * @return The user from the database matching the given userName, otherwise null.
     * @throws DAOException If something fails at database level.
     */
	 public User findUserByUserName(String userName) throws DAOException;
	 
	 
	 /**
     * Returns the user from the database matching the given username and password, otherwise null.
     * @param username The username of the user to be returned.
     * @param password The password of the user to be returned.
     * @return The user from the database matching the given email and password, otherwise null.
     * @throws DAOException If something fails at database level.
     */
    public User find(String username, String password) throws DAOException;

    
    /**
     * Returns a list of all users from the database ordered by user ID. The list is never null and
     * is empty when the database does not contain any user.
     * @return A list of all users from the database ordered by user ID.
     * @throws DAOException If something fails at database level.
     */
    public ArrayList<User> findAll() throws DAOException;

    /**
     * Returns a list of all users from the database of a given type ordered by user ID. The list is never null and
     * is empty when the database does not contain any user.
     * @param type: The type of the user: Professor/Student
     * @return A list of all users of a given type from the database ordered by user ID.
     * @throws DAOException If something fails at database level.
     */
    public ArrayList<User> findAllByType(String type) throws DAOException;

    /**
     * Returns a list of all users from the database of a given team ordered by user ID. The list is never null and
     * is empty when the database does not contain any user.
     * @param teamId: The teamId of the team the users belong to.
     * @return A list of all users of a given team from the database ordered by user ID.
     * @throws DAOException If something fails at database level.
     */
    public ArrayList<User> findAllByTeam(int teamId) throws DAOException;

    /**
     * Returns a list of all users from the database of a given course ordered by user ID. The list is never null and
     * is empty when the database does not contain any user.
     * @param courseId: The courseId of the course the users belong to.
     * @return A list of all users from the database ordered by user ID.
     * @throws DAOException If something fails at database level.
     */
    public ArrayList<User> findAllByCourse(String courseId) throws DAOException;

    
	 /**
     * Create the given user in the database. The username must be unique, otherwise it will throw
     * IllegalArgumentException.  
     * @param user The user to be created in the database.
     * @throws IllegalArgumentException If the username exists
     * @throws DAOException If something fails at database level.
     */
	  public int insertUser(User user) throws IllegalArgumentException, DAOException;
	  
	  /**
	     * Assign the given user to the course in the database. The userId must be unique, otherwise it will throw
	     * IllegalArgumentException.  
	     * @param userId The userId to be assigned to the course in the database.
	     * @throws IllegalArgumentException If the userId and courseId exists
	     * @throws DAOException If something fails at database level.
	     */	  
	  public int assignUserToCourse(String userId, String courseId);
	  
	  /**
	     * Assign the given users to the course in the database. The userIds must be unique, otherwise it will throw
	     * IllegalArgumentException.  
	     * @param ArrayList<userId> The userIds to be assigned to the course in the database.
	     * @throws IllegalArgumentException If the userId and courseId exists
	     * @throws DAOException If something fails at database level.
	     */	  
	  public int assignUsersToCourse(String userIds, String courseId);  

	  
	  /**
	     * Update the given user in the database. The username must not be null, otherwise it will throw
	     * IllegalArgumentException.
	     * @param user The user to be updated in the database.
	     * @throws IllegalArgumentException If the username is null.
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean updateUser(User user) throws DAOException;
	  
	  /**
	     * Delete the given user from the database. 
	     * @param user The user to be deleted from the database.
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean deleteUser(String userName) throws DAOException;
	  
	  /**
	     * Change the user's active status
	     * @param username The userName which is to be checked in the database.
	     * @param status The active status: 1 active, 0 not active
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean updateUserActiveStatus(String userName, boolean status) throws DAOException;
	  
	  /**
	     * Change the user's active status
	     * @param username The userName which is to be checked in the database.
	     * @param status The online status: 1 on line, 0 not on line
	     * @throws DAOException If something fails at database level.
	     */
	  public boolean updateUserOnlineStatus(String userName, boolean status) throws DAOException;

	  public RowSet selectUsersRS();
	  public Collection<User> selectUsersTO();
	}

